package com.ruoyi.project.system.service.impl;

import java.util.List;

import com.ruoyi.project.system.domain.CourseQuestionCfg;
import com.ruoyi.project.system.domain.QuestionStore;
import com.ruoyi.project.system.mapper.CourseQuestionCfgMapper;
import com.ruoyi.project.system.mapper.QuestionStoreMapper;
import com.ruoyi.project.system.service.IQuestionStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * [题库]Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-10-07
 */
@Service
public class QuestionStoreServiceImpl implements IQuestionStoreService
{
    @Autowired
    private QuestionStoreMapper questionStoreMapper;
@Autowired
    private CourseQuestionCfgMapper courseQuestionCfgMapper;

    /**
     * 查询[题库]
     * 
     * @param id [题库]ID
     * @return [题库]
     */
    @Override
    public QuestionStore selectQuestionStoreById(Integer id)
    {
        return questionStoreMapper.selectQuestionStoreById(id);
    }

    /**
     * 查询[题库]列表
     * 
     * @param questionStore [题库]
     * @return [题库]
     */
    @Override
    public List<QuestionStore> selectQuestionStoreList(QuestionStore questionStore)
    {
        return questionStoreMapper.selectQuestionStoreList(questionStore);
    }

    /**
     * 新增[题库]
     * 
     * @param questionStore [题库]
     * @return 结果
     */
    @Override
    public int insertQuestionStore(QuestionStore questionStore)
    {

//        Integer id =  questionStoreMapper.insertQuestionStore(questionStore);
//
//        CourseQuestionCfg cqc = new CourseQuestionCfg();
//        cqc.setQuestionId(questionStore.getId().longValue());
//        cqc.setCourseCatalogId(questionStore.getCourseCatalogId());
//
//        return courseQuestionCfgMapper.insertCourseQuestionCfg(cqc);

        return questionStoreMapper.insertQuestionStore(questionStore);
    }

    /**
     * 修改[题库]
     * 
     * @param questionStore [题库]
     * @return 结果
     */
    @Override
    public int updateQuestionStore(QuestionStore questionStore)
    {
//        CourseQuestionCfg cqc = new CourseQuestionCfg();
//        cqc.setQuestionId(questionStore.getId().longValue());
//        cqc.setCourseCatalogId(questionStore.getCourseCatalogId());
//        courseQuestionCfgMapper.updateCourseQuestionCfg(cqc);
//        return questionStoreMapper.updateQuestionStore(questionStore);
        return questionStoreMapper.updateQuestionStore(questionStore);
    }

    /**
     * 批量删除[题库]
     * 
     * @param ids 需要删除的[题库]ID
     * @return 结果
     */
    @Override
    public int deleteQuestionStoreByIds(Integer[] ids)
    {

        for (Integer id : ids) {
            courseQuestionCfgMapper.deleteCourseQuestionCfgByQueId(id);
        }
        return questionStoreMapper.deleteQuestionStoreByIds(ids);
    }

    /**
     * 删除[题库]信息
     * 
     * @param id [题库]ID
     * @return 结果
     */
    @Override
    public int deleteQuestionStoreById(Integer id)
    {
        return questionStoreMapper.deleteQuestionStoreById(id);
    }
}
